home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C/C++ Users Group Library 1996 July
/
C-C++ Users Group Library July 1996.iso
/
listings
/
v_12_03
/
saks
/
polygon.h
< prev
next >
Wrap
C/C++ Source or Header
|
1994-01-12
|
870b
|
64 lines
Listing 3 - the shape hierarchy with rectangle and triangle
derived from abstract base class polygon
class shape
{
public:
...
virtual shape *clone() const = 0;
...
};
...
class circle : public shape
{
public:
shape *clone() const;
...
};
shape *circle::clone() const
{
return new circle(*this);
}
...
class polygon : public shape
{
public:
// shape *clone() const = 0; // still pure
...
};
...
class rectangle : public polygon
{
public:
shape *clone() const;
...
};
shape *rectangle::clone() const
{
return new rectangle(*this);
}
...
class triangle : public polygon
{
public:
shape *clone() const;
...
};
shape *triangle::clone() const
{
return new triangle(*this);
}
...